package com.hc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@EnableOpenApi
@Configuration
public class SwaggerConfiguration {
    @Bean
    public Docket createRestApi() {
        //new Docket(DocumentationType.SWAGGER_2)
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.hc"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("梁云亮个人博客API")
                .description("梁云亮擅长SpringBoot,开发工具,JavaSE,等方面的知识,梁云亮关注Elasticsearch,架构,Redis,Linux,MySQL,Java,分布式,Spring Boot,Spring领域.")
                .contact(new Contact("梁云亮", "https://blog.csdn.net/lianghecai52171314", "369950806@qq.com"))
                .version("1.0")
                .build();
    }
}
